<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <!--随机点名-->
    <button>点名</button>
    <h3>显示名字</h3>
    <script>
        const btn=document.querySelector('button');
        const text=document.querySelector('h3');
        let arr=['a','b','c','d'];
        btn.addEventListener('click',function(){
            //获取数组的随机索引值num[0-arr.length]
            let num=Math.floor(Math.random()*arr.length);
            //通过num获取数组中的随机值
            text.innerHTML=arr[num];
        })
    </script>
</body>
</html>